import com.sun.source.tree.ParenthesizedPatternTree;

import javax.swing.*;
import java.util.Random;

public class demo3 {
    public static void main(String[] args) {
        Random random = new Random();
        int randomNum = random.nextInt(100) + 1;
        System.out.println(randomNum);

        while (true) {
           String guessNumStr= JOptionPane.showInputDialog("请输入猜测的数");
           int guessNum=Integer.parseInt(guessNumStr);
           if (guessNum < randomNum)
               JOptionPane.showInputDialog(null,"猜小了");
           else if (guessNum > randomNum)
               JOptionPane.showInputDialog(null,"猜大了");
           else {
               JOptionPane.showInputDialog(null, "猜对了");
               break;
           }
        }
    }

}